local skel = fk.CreateSkill({
  name = "lb__juexiang",
})

local DIY = require "packages.diy_utility.diy_utility"

Fk:loadTranslationTable {
  ["lb__juexiang"] = "绝响",
  [":lb__juexiang"] = "每回合结束时，你可获得本回合弃牌堆中所有与<a href=':lb__jueyi'><font color='red'>〖绝意〗</font></a>剩余花色相同的牌并执行一个弃牌阶段。",

  ["@[suits]lb__juexiang"] = "绝响",
  ["#lb__juexiang"] = "绝响：你可以获得这些牌并执行一个弃牌阶段",

  ["$lb__juexiang1"] = "崭新的未来！",
  ["$lb__juexiang2"] = "星核，改写一切！",
}

skel:addEffect(fk.TurnEnd, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and #player:getTableMark("@[suits]lb__jueyi") > 0 
    and table.find(DIY.getCenterCards(player.room), function (id)
      return table.contains(player:getTableMark("@[suits]lb__jueyi"), Fk:getCardById(id).suit)
    end)
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local cards = table.filter(DIY.getCenterCards(room), function(id)
      return table.contains(player:getTableMark("@[suits]lb__jueyi"), Fk:getCardById(id).suit)
    end)
    if #cards > 0 then
      if room:askToViewCardsAndChoice(player, {
            cards = cards,
            skill_name = skel.name,
            choices = { "OK", "Cancel" },
            prompt = "#lb__juexiang",
          }) == "OK" then
        event:setCostData(self, { cards = cards })
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local cards = event:getCostData(self).cards
    player.room:obtainCard(player, cards, true, fk.ReasonJustMove, player, skel.name)
    player:gainAnExtraPhase(Player.Discard, skel.name, false)
  end,
})

skel:addAcquireEffect(function(self, player, is_start)
  player.room:addSkill("#CenterArea")
end)


return skel